Skip to main content

All Questions

-4votes
1answer
98views

Is it possible a class method have the same name as an existing function? [closed]

Courtesy link: What Are The Specific Meanings Of The Terms: Functions, Methods, Procedures, and Subroutines? What's the difference between a function and a method? In the linked question: function,...
Arunabh's user avatar
38votes
10answers
10kviews

Why do heavily object-oriented languages avoid having functions as a primitive type?

As has been covered to the point of parody, heavily object-oriented languages, such as C# or Java, tend to lack the feature of having functions as a primitive type. You can argue about whether or not ...
J. Mini's user avatar
  • 1,007
3votes
3answers
314views

Referencing transient class attributes

I've just started dipping my feet into OOP. Is it considered bad practice to have classes that reference attributes that depend on another function being called and thus may not exist (version 1)? I'...
Tim Kirkwood's user avatar
0votes
1answer
527views

Python: Function pipeline with multiple return/input values, or use OOP? Best Practices?

I have a 'processing' function and a 'serializing' function. Currently the processor returns 4 different types of data structures to be serialized in different ways. Looking for the best practise on ...
Jamal Rahman's user avatar
2votes
1answer
377views

How to choose between functions and objects

I have seen different approaches and it is not clear to me which one is the correct one. Some developers use lots of small, very specific objects, and compose them in some way to achieve their goal. ...
DT1's user avatar
  • 209
1vote
1answer
111views

Pure functions with a connection to a system

What's a good place to put pure functions that have connections to a system? public class Core { System system; } public class System { SubSystem subSystem; // subSystem.Multiply(a, b); }...
Iggy's user avatar
  • 127
8votes
4answers
688views

Is SRP an ambiguous principle? [closed]

I've been aware of SOLID for many years now and I've always though about "OLID" was a good set of design principles to follow... problem is I've always found difficulties with the "S", I've always ...
BPL's user avatar
  • 465
0votes
1answer
1kviews

How to call an unknown member function through an instance of a related class?

I have two classes. The first, called Game_Events, controls the objects and manages the general tasks. The second, called Button, is for one of those object instances. The example below is wrong but ...
Andre Marques's user avatar
1vote
2answers
304views

Are any side effects not concrete side effects?

In Chapter 23 of "Object Oriented Software Construction" (1988), Betrand Meyer makes a distinction between side effects, concrete side effects, and abstract side effects. Meyer defines a side effect ...
Ceasar's user avatar
15votes
4answers
4kviews

Are first-class functions a substitute for the Strategy pattern?

The Strategy design pattern is often regarded as a substitute for first-class functions in languages that lack them. So for example say you wanted to pass functionality into an object. In Java you'd ...
Aviv Cohn's user avatar
29votes
8answers
9kviews

Is splitting up a function into several inner functions an anti-pattern? [duplicate]

Imagine a long and complicated process, which is started by calling function foo(). There are several consecutive steps in this process, each of them depending on result of the previous step. The ...
Stas Bichenko's user avatar
0votes
3answers
1kviews

Reason to treat internal class variables and functions inside a class as "separate" entities

Note: there is a similar question that addresses my subject: Better style for member variables? ... but that question does not address "dealing with large legacy code base and comprehension of ...
Dennis's user avatar
  • 8,257
46votes
6answers
10kviews

Why is "tight coupling between functions and data" bad?

I found this quote in "The Joy of Clojure" on p. 32, but someone said the same thing to me over dinner last week and I've heard it other places as well: [A] downside to object-oriented programming ...
GlenPeterson's user avatar
9votes
6answers
9kviews

Naming functions that retrieve a value

I have this personal rule to start all function/method names with a verb. My verb of choice for functions or methods that get a value based on some data structure or object is get. I'm wondering if ...
futlib's user avatar
  • 2,205
3votes
2answers
364views

Should I use chained functions in Java?

From time to time, I'll have a class in Java that takes a multitude of parameters, however, sometimes when I am creating an object of this class, I don't need to use all the parameters. As of now, I ...
Ivan's user avatar
  • 1,017

close